﻿using NUnit.Framework;
using System;

namespace RenewalProjects.Libraries.SharedCode.Tests
{
	[TestFixture]
	public class LoggingFixture
	{
		[Test]
		public void Test_various_output_logging_methods()
		{
			Logging.Debug("Debug message");
			Logging.Debug("Debug message : {0}", "Arg");
			Logging.Info("Info message");
			Logging.Info("Info message : {0}", "Arg");
			Logging.Warn("Warn message");
			Logging.Warn("Warn message : {0}", "Arg");
			Logging.Error("Error message");
			Logging.Error(ExceptionWithStacktrace("Error exception"), "Error message with exception");
			Logging.Error("Error message : {0}", "Arg");
			Logging.Error(ExceptionWithStacktrace("Error exception"), "Error message with exception : {0}", "Arg");
			Logging.Fatal("Fatal message");
			Logging.Fatal(ExceptionWithStacktrace("Fatal exception"), "Fatal message with exception");
			Logging.Fatal("Fatal message : {0}", "Arg");
			Logging.Fatal(ExceptionWithStacktrace("Fatal exception"), "Fatal message with exception : {0}", "Arg");
		}

		private static Exception ExceptionWithStacktrace(string exceptionMessage, Exception innerException = null)
		{
			try
			{
				throw new Exception(exceptionMessage, innerException);
			}
			catch(Exception ex)
			{
				return ex;
			}
		}
	}
}